from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.
# users/models.py
from django.db import models


class User(AbstractUser):
    openid = models.CharField(max_length=64, unique=True)
    avatar_url = models.URLField(blank=True, null=True)
    bio = models.TextField(blank=True)
    # 不需要 username 字段时可以重写 USERNAME_FIELD

    def __str__(self):
        return self.username

class UserFollow(models.Model):
    follower = models.ForeignKey(User, related_name='following', on_delete=models.CASCADE)
    followee = models.ForeignKey(User, related_name='followers', on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        unique_together = ('follower', 'followee')


